//
//  secondScrollView.m
//  UI09_Homework
//
//  Created by dllo on 16/6/16.
//  Copyright © 2016年 司昌宝. All rights reserved.
//

#import "secondScrollView.h"

@implementation secondScrollView

-(instancetype)initWithFrame:(CGRect)frame withImageArray:(NSArray *)imageArray{
    self = [super initWithFrame:frame];
    if (self) {
        self.imageArray = imageArray;
        [self setProprety];
    }
    return self;
}

-(void)setProprety{
    self.contentSize = CGSizeMake(self.frame.size.width * (self.imageArray.count+ 2), 0);
    self.pagingEnabled = YES;
    NSMutableArray *tempArray = [NSMutableArray arrayWithArray:self.imageArray];
    [tempArray insertObject:[self.imageArray objectAtIndex:self.imageArray.count - 1] atIndex:0];
    [tempArray addObject:[self.imageArray objectAtIndex:0]];
    
    for (NSInteger i = 0;i < tempArray.count;i++){
        UIImageView *imageView = [[UIImageView alloc] initWithImage:tempArray[i]];
        imageView.frame = CGRectMake(self.frame.size.width * i, 0, self.frame.size.width, self.frame.size.height);
        [self addSubview:imageView];
    }
    
}


@end
